package br.com.base.apresentacao;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.protocol.http.WebApplication;
import org.springframework.beans.BeansException;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import br.com.base.negocios.fachada.IFachada;
import br.com.base.negocios.fachada.imp.Fachada;

public abstract class PaginaGenerica extends WebPage implements IPagina {

	private IFachada fachada;

	private IPagina veioDe;

	public PaginaGenerica() {

		try {
			WebApplicationContext ctx = WebApplicationContextUtils
					.getRequiredWebApplicationContext(WebApplication.get()
							.getServletContext());
			this.fachada = (Fachada) ctx.getBean("fachada");
		} catch (BeansException e) {
			e.printStackTrace();
		}
	}

	public IFachada getFachada() {
		return fachada;
	}

	public IPagina getVeioDe() {
		return this.veioDe;
	}

	public abstract void montarPagina();

	public void setFachada(IFachada fachada) {
		this.fachada = fachada;
	}

	public void setVeioDe(IPagina pagina) {
		this.veioDe = pagina;
	}

}
